package lib

import (
	"encoding/json"
	"github.com/go-xorm/xorm"
)

func Db(index int) *xorm.Engine {
	return UseHandle(index)
}

// 生成json
func JsonResponse(code int, msg string, data interface{}) string {
	response := make(map[string]interface{})
	response["code"] = code
	response["msg"] = msg
	response["data"] = data

	js, err := json.Marshal(response)
	if err != nil {
		return err.Error()
	}
	return string(js)
}
